package com.alibaba.user.controller.v1;

import com.alibaba.api.controller.v1.UserControllerApi;
import com.alibaba.api.dtos.RequestDTO;
import com.alibaba.api.dtos.ResponseResult;
import com.alibaba.user.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/user")
public class UserController implements UserControllerApi {

    @Autowired
    private UserService userService;

    @PostMapping("/register")
    @Override
    public ResponseResult register(@RequestBody RequestDTO requestDTO) {
        return userService.register(requestDTO);
    }

    @GetMapping ("/login")
    @Override
    public ResponseResult login(String phone, String code) {
        return userService.login(phone, code);
    }

    @GetMapping("/code")
    @Override
    public ResponseResult code(String phone) {
        return userService.code(phone);
    }
}
